<!--
 * @description  : 市管检查-动态组件
 * @descriptionDetail: 市管检查-流入问题、流出问题、规范经营问题、
  许可证问题、违规问题、线索登记、备忘录 动态组件
 * @copyright    : 浙江烟草
 * @author       : sy
 * @create       : 2022-07-09 18:43:02
-->
<template>
  <view>
    <theme-navbar
      :isBack="true"
      :is-white="false"
      :title="menuData.label"
      :customBack="handlerBack"
      style="z-index: 99999"
    >
      <view class="nav-right-icon" v-if="!isDisabled" @tap="handlerSure">
        确定
      </view>
    </theme-navbar>
    <view>
      <!-- <u-card title="检查作业指导" :head-style="{'fontWeight': 600}" v-if="menuData.checkGuides.length > 0">
        <view class="" slot="body">
          <u-tag :text="gTxt" mode="plain" shape="circle" type="warning" style="margin-right: 5px;" v-for="(gTxt, idx) in menuData.checkGuides" :key="idx" />
        </view>
      </u-card>
      <u-gap height="15" bg-color="#eee" v-if="menuData.checkGuides.length > 0"></u-gap> -->
      <!-- 第一层 -->
      <view v-for="(item, idx) in records" :key="idx">
        <!-- 开关选择 -->
        <u-cell-item 
          :arrow="false" 
          class="cell" 
          :title-style="mainLabelStyle"
          v-if="item.operateType == '91401'"
        >
          <view slot="title" style="display: inline-flex;flex-direction: row;">
            <view class="u-cell_title" style="margin-right: 10rpx;">
              {{ item.itemName }}
            </view>
            <u-icon :size="35" :name="getWarningInfo(item.itemUuid)" @click="tapWarning(item.itemUuid)" :custom-style="wiIconStyle"></u-icon>
          </view>
          <!-- 已外流设置为只读  || item.itemUuid == '34020203'-->
          <u-switch :disabled="isDisabled" slot="right-icon" v-model="checkObj[item.checkKey]" @change="handlerSwitch($event, item)"></u-switch>
        </u-cell-item>
        <!-- 选择框 -->
        <u-cell-item class="cell" :title-style="mainLabelStyle" v-if="item.operateType == '91402'">
          <view slot="title" style="display: inline-flex;flex-direction: row;">
            <view class="u-cell_title" style="margin-right: 10rpx;">
              {{ item.itemName }}
            </view>
            <u-icon :size="35" :name="getWarningInfo(item.itemUuid)" @click="tapWarning(item.itemUuid)" :custom-style="wiIconStyle"></u-icon>
          </view>
          <u-input input-align="right" :custom-style="pointerStyle" :disabled="true" placeholder="请选择" slot="right-icon" v-model="checkObj[item.checkKey]" @tap="handlerSelShow(item)" />
        </u-cell-item>
        <!-- 输入框 -->
        <u-cell-item :arrow="false" class="cell" :title-style="mainLabelStyle" v-if="item.operateType == '91403'">
          <view slot="title" style="display: inline-flex;flex-direction: row;">
            <view class="u-cell_title" style="margin-right: 10rpx;">
              {{ item.itemName }}
            </view>
            <u-icon :size="35" :name="getWarningInfo(item.itemUuid)" @click="tapWarning(item.itemUuid)" :custom-style="wiIconStyle"></u-icon>
          </view>
          <u-input input-align="right" :disabled="isDisabled" slot="right-icon" v-model="checkObj[item.checkKey]" />
        </u-cell-item>
        <!-- 区划选择 -->
        <u-cell-item class="cell" :title-style="mainLabelStyle" v-if="item.operateType == '91406'">
          <view slot="title" style="display: inline-flex;flex-direction: row;">
            <view class="u-cell_title" style="margin-right: 10rpx;">
              {{ item.itemName }}
            </view>
            <u-icon :size="35" :name="getWarningInfo(item.itemUuid)" @click="tapWarning(item.itemUuid)" :custom-style="wiIconStyle"></u-icon>
          </view>
          <u-input input-align="right" :custom-style="pointerStyle" :disabled="true" placeholder="请选择" slot="right-icon" v-model="checkObj[item.checkKey]" />
        </u-cell-item>
        <!-- TODO 经营场所坐标 -->
        <u-cell-item class="cell" :title-style="mainLabelStyle" v-if="item.operateType == '91407'">
          <view slot="title" style="display: inline-flex;flex-direction: row;">
            <view class="u-cell_title" style="margin-right: 10rpx;">
              {{ item.itemName }}
            </view>
            <u-icon :size="35" :name="getWarningInfo(item.itemUuid)" @click="tapWarning(item.itemUuid)" :custom-style="wiIconStyle"></u-icon>
          </view>
          <u-input input-align="right" :custom-style="pointerStyle" :disabled="true" slot="right-icon" v-model="checkObj[item.checkKey]" />
        </u-cell-item>
        <!-- textarea大文本 -->
        <u-field
          type="textarea"
          placeholder="请输入"
          :label="item.itemName"
          label-width="120"
          style="height: 120px;"
          :disabled="isDisabled"
          v-if="item.operateType == '91404'"
          v-model="checkObj[item.checkKey]"
        >
        </u-field>
        <!-- 图片上传 -->
        <u-card :title="item.itemName" v-else-if="item.operateType == '91405'">
          <view class="" slot="body">
            <view class="u-body-item u-flex u-border-bottom u-col-between u-p-t-0">
              <view class="u-body-item-title u-line-2">
                <upload-images
                  :url="uploadFile"
                  :length="picMaxCount"
                  :header="header"
                  :bizId="menuData.checkInfo.checkUuid + '-' +item.itemUuid"
                  :extForm="{fiGroupCode: $FILE_GROUP_TYPE.m_check_attr,bizId:menuData.checkInfo.checkUuid + '-' +item.itemUuid, itemUuid: item.itemUuid}"
                  :canDel="!isDisabled"
                  :del-url="delUrl"
                  :can-add="!isDisabled"
                  :renderImages="renderImages"
                  :onSuccess="handlerUploadImg"
                  :ref="'upload' + item.itemUuid"
                >
                </upload-images>
              </view>
            </view>
          </view>
        </u-card>
        <!-- 第二层 -->
        <view style="padding-left: 10px;" v-show="checkObj[item.checkKey]">
          <u-cell-item
            class="cell cell-sub"
            title="处理方式"
            :value="item.checkHandleResultLabel" 
            :arrow="true"
            v-if="item.dealList && item.dealList.length > 0"
            @click="handlerShowSelect(item)"
          >
            <view slot="title" style="display: inline-flex;flex-direction: row;">
              <view class="u-cell_title" style="margin-right: 10rpx;">
                处理方式
              </view>
              <!-- <u-icon :size="35" :name="getWarningInfo(item.itemUuid)" @click="tapWarning(item.itemUuid)" :custom-style="wiIconStyle"></u-icon> -->
            </view>
          </u-cell-item>         
          <view v-for="(record, rIdx) in item.workItems" :key="rIdx">
            <!-- 是否选择 -->
            <u-cell-item class="cell cell-sub" :arrow="false" v-if="record.operateType == '91401'">
              <view slot="title" style="display: inline-flex;flex-direction: row;">
                <view class="u-cell_title" style="margin-right: 10rpx;">
                  {{ record.itemName }}
                </view>
                <u-icon :size="35" :name="getWarningInfo(record.itemUuid)" @click="tapWarning(record.itemUuid)" :custom-style="wiIconStyle"></u-icon>
              </view>
              <u-switch :disabled="isDisabled" slot="right-icon" v-model="checkObj[record.checkKey]" @change="handlerSwitch($event, record)"></u-switch>
            </u-cell-item>
            <u-input
              v-if="record.operateType == '91403'"
              style="margin: 5px 15px 5px 0px;"
              :placeholder="'请输入' + record.itemName"
              type="text"
              :border="true" 
              :disabled="isDisabled"
              v-model="checkObj[record.checkKey]"
            />
            <!-- textarea大文本 -->
            <u-field
              type="textarea"
              placeholder="请输入"
              :label="record.itemName"
              label-width="120"
              style="height: 120px;"
              :disabled="isDisabled"
              v-if="record.operateType == '91404'"
              v-model="checkObj[record.checkKey]"
            >
            </u-field>
            <!-- 添加卷烟 -->
            <u-cell-item class="cell cell-sub" :arrow="false" v-else-if="record.operateType == '91411'">
              <view slot="title" style="display: inline-flex;flex-direction: row;">
                <view class="u-cell_title" style="margin-right: 10rpx;">
                  {{ record.itemName }}
                </view>
                <u-icon :size="35" :name="getWarningInfo(record.itemUuid)" @click="tapWarning(record.itemUuid)" :custom-style="wiIconStyle"></u-icon>
              </view>
              <u-icon name="plus-circle" :color="$theme.u_type_primary" size="38" v-if="!isDisabled" slot="right-icon" @tap="handlerAddCig(record)"></u-icon>
            </u-cell-item>
            <!-- 收购人员登记 -->
            <u-cell-item class="cell cell-sub" :arrow="false" v-else-if="record.operateType == '91412'">
              <view slot="title" style="display: inline-flex;flex-direction: row;">
                <view class="u-cell_title" style="margin-right: 10rpx;">
                  {{ record.itemName }}
                </view>
                <u-icon :size="35" :name="getWarningInfo(record.itemUuid)" @click="tapWarning(record.itemUuid)" :custom-style="wiIconStyle"></u-icon>
              </view>
              <u-icon name="plus-circle" :color="$theme.u_type_primary" size="38" v-if="!isDisabled" slot="right-icon" @tap="handlerAddPersons(record)"></u-icon>
            </u-cell-item>
            <!-- 添加卷烟信息 -->
            <view style="padding-left: 10px;" v-if="cigsMap[record.itemUuid]">
              <u-row gutter="16" v-for="(sItem, sIdx) in cigsMap[record.itemUuid]" :key="sIdx">
                <u-col span="7">
                  <view class="title" v-if="!isDisabled">
                    {{ sItem.productName }}
                  </view>
                  <view class="title view-title" v-else @tap="handlerEditCig(sItem, record.itemUuid)">
                    {{ sItem.productName }}
                  </view>
                </u-col>
                <u-col span="3">
                  <view class="sub-title">
                    {{ sItem.qty }}条
                  </view>
                </u-col>
                <u-col span="2" style="text-align:center;display:flex;">
                  <u-icon
                    name="edit-pen"
                    :color="$theme.u_type_primary"
                    size="32"
                    style="flex: 1;"
                    v-if="!isDisabled"
                    @tap="handlerEditCig(sItem, record.itemUuid)"
                  ></u-icon>
                  <u-icon
                    name="trash"
                    color="red"
                    size="32"
                    style="margin-left: 5px;flex: 1;" 
                    v-if="!isDisabled"
                    @tap="handlerDeleteCig(sItem, record.itemUuid)"
                  ></u-icon>
                </u-col>
              </u-row>
            </view>
            <!-- 嫌疑人信息 -->
            <view style="padding-left: 10px;" v-if="personsMap[record.itemUuid]">
              <u-row gutter="16" v-for="(pItem, pIdx) in personsMap[record.itemUuid]" :key="pIdx">
                <u-col span="9">
                  <view class="title" v-if="!isDisabled">
                    {{ pItem.personName }}
                  </view>
                  <view class="title view-title" v-else @tap="handlerEditPerson(pItem, record.itemUuid)">
                    {{ pItem.personName }}
                  </view>
                </u-col>
                <u-col span="3" style="text-align:center;display:flex;">
                  <u-icon
                    name="edit-pen"
                    :color="$theme.u_type_primary"
                    size="32"
                    style="flex: 1;"
                    v-if="!isDisabled"
                    @tap="handlerEditPerson(pItem, record.itemUuid)"
                  ></u-icon>
                  <u-icon
                    name="trash"
                    color="red"
                    size="32"
                    style="margin-left: 5px;flex: 1;" 
                    v-if="!isDisabled"
                    @tap="handlerDeletePerson(pItem, record.itemUuid)"
                  ></u-icon>
                </u-col>
              </u-row>
            </view>
            <!-- 图片上传 -->
            <u-card :title="record.itemName" v-else-if="record.operateType == '91405'">
              <view class="" slot="body">
                <view class="u-body-item u-flex u-border-bottom u-col-between u-p-t-0">
                  <view class="u-body-item-title u-line-2">
                    <upload-images
                      :url="uploadFile"
                      :length="picMaxCount"
                      :header="header"
                      :bizId="menuData.checkInfo.checkUuid + '-' +record.itemUuid"
                      :extForm="{fiGroupCode: $FILE_GROUP_TYPE.m_check_attr,bizId:menuData.checkInfo.checkUuid + '-' +record.itemUuid, itemUuid: record.itemUuid}"
                      :canDel="!isDisabled"
                      :del-url="delUrl"
                      :can-add="!isDisabled"
                      :renderImages="renderImages"
                      :onSuccess="handlerUploadImg"
                      :ref="'upload' + record.itemUuid"
                    >
                    </upload-images>
                  </view>
                </view>
              </view>
            </u-card>
            
            <!-- 第三层 -->
            <view style="padding-left: 10px;" v-show="checkObj[record.checkKey]">
              <u-cell-item
                class="cell cell-sub"
                :value="record.checkHandleResultLabel" 
                :arrow="true"
                v-if="record.dealList && record.dealList.length > 0"
                @click="handlerShowSelect(record)"
              >
                <view slot="title" style="display: inline-flex;flex-direction: row;">
                  <view class="u-cell_title" style="margin-right: 10rpx;">
                    处理方式
                  </view>
                  <!-- <u-icon :size="35" :name="getWarningInfo(record.itemUuid)" @click="tapWarning(nRecord.itemUuid)" :custom-style="wiIconStyle"></u-icon> -->
                </view>
              </u-cell-item>
              <view v-for="(nRecord, nrIdx) in record.workItems" :key="nrIdx">
                <!-- 是否选择 -->
                <u-cell-item class="cell cell-sub" :arrow="false" v-if="nRecord.operateType == '91401'">
                  <view slot="title" style="display: inline-flex;flex-direction: row;">
                    <view class="u-cell_title" style="margin-right: 10rpx;">
                      {{ nRecord.itemName }}
                    </view>
                    <u-icon :size="35" :name="getWarningInfo(nRecord.itemUuid)" @click="tapWarning(nRecord.itemUuid)" :custom-style="wiIconStyle"></u-icon>
                  </view>
                  <u-switch :disabled="isDisabled" slot="right-icon" v-model="checkObj[nRecord.checkKey]" @change="handlerSwitch($event, nRecord)"></u-switch>
                </u-cell-item>
                <!-- 添加卷烟 -->
                <u-cell-item class="cell cell-sub" :arrow="false" v-else-if="nRecord.operateType == '91411'">
                  <view slot="title" style="display: inline-flex;flex-direction: row;">
                    <view class="u-cell_title" style="margin-right: 10rpx;">
                      {{ nRecord.itemName }}
                    </view>
                    <u-icon :size="35" :name="getWarningInfo(nRecord.itemUuid)" @click="tapWarning(nRecord.itemUuid)" :custom-style="wiIconStyle"></u-icon>
                  </view>
                  <u-icon name="plus-circle" :color="$theme.u_type_primary" size="38" v-if="!isDisabled" slot="right-icon" @tap="handlerAddCig(nRecord)"></u-icon>
                </u-cell-item>
                <!-- 收购人员登记 -->
                <u-cell-item class="cell cell-sub" :arrow="false" v-else-if="nRecord.operateType == '91412'">
                  <view slot="title" style="display: inline-flex;flex-direction: row;">
                    <view class="u-cell_title" style="margin-right: 10rpx;">
                      {{ nRecord.itemName }}
                    </view>
                    <u-icon :size="35" :name="getWarningInfo(nRecord.itemUuid)" @click="tapWarning(nRecord.itemUuid)" :custom-style="wiIconStyle"></u-icon>
                  </view>
                  <u-icon name="plus-circle" :color="$theme.u_type_primary" size="38" v-if="!isDisabled" slot="right-icon" @tap="handlerAddPersons(nRecord)"></u-icon>
                </u-cell-item>
                <!-- 涉案车辆登记 -->
                <u-cell-item class="cell cell-sub" :arrow="false" v-else-if="nRecord.operateType == '91419'">
                  <view slot="title" style="display: inline-flex;flex-direction: row;">
                    <view class="u-cell_title" style="margin-right: 10rpx;">
                      {{ nRecord.itemName }}
                    </view>
                    <u-icon :size="35" :name="getWarningInfo(nRecord.itemUuid)" @click="tapWarning(nRecord.itemUuid)" :custom-style="wiIconStyle"></u-icon>
                  </view>
                  <u-icon name="plus-circle" :color="$theme.u_type_primary" size="38" v-if="!isDisabled" slot="right-icon" @tap="handlerAddCar(nRecord)"></u-icon>
                </u-cell-item>  
                <!-- 涉案窝点登记 -->
                <u-cell-item class="cell cell-sub" :arrow="false" v-else-if="nRecord.operateType == '91420'">
                  <view slot="title" style="display: inline-flex;flex-direction: row;">
                    <view class="u-cell_title" style="margin-right: 10rpx;">
                      {{ nRecord.itemName }}
                    </view>
                    <u-icon :size="35" :name="getWarningInfo(nRecord.itemUuid)" @click="tapWarning(nRecord.itemUuid)" :custom-style="wiIconStyle"></u-icon>
                  </view>
                  <u-icon name="plus-circle" :color="$theme.u_type_primary" size="38" v-if="!isDisabled" slot="right-icon" @tap="handlerAddDens(nRecord)"></u-icon>
                </u-cell-item>
                <!-- 关联 -->
                <u-cell-item class="cell cell-sub" :arrow="false" v-else-if="nRecord.operateType == '91421'" @click="handlerMergeGis(nRecord)">
                  <view slot="title" style="display: inline-flex;flex-direction: row;">
                    <view class="u-cell_title" style="margin-right: 10rpx;">
                      {{ nRecord.itemName + (nRecord.gisData || '') }}
                    </view>
                    <u-icon :size="35" :name="getWarningInfo(nRecord.itemUuid)" @click="tapWarning(nRecord.itemUuid)" :custom-style="wiIconStyle"></u-icon>
                  </view>
                  <u-icon name="map" :color="$theme.u_type_primary" size="38" v-if="!isDisabled" slot="right-icon"></u-icon>
                </u-cell-item>
                <!-- 添加卷烟信息 -->
                <view style="padding-left: 10px;" v-if="cigsMap[nRecord.itemUuid]">
                  <u-row gutter="16" v-for="(sItem, sIdx) in cigsMap[nRecord.itemUuid]" :key="sIdx">
                    <u-col span="7">
                      <view class="title" v-if="!isDisabled">
                        {{ sItem.productName }}
                      </view>
                      <view class="title view-title" v-else @tap="handlerEditCig(sItem, nRecord.itemUuid)">
                        {{ sItem.productName }}
                      </view>
                    </u-col>
                    <u-col span="3">
                      <view class="sub-title">
                        {{ sItem.qty }}条
                      </view>
                    </u-col>
                    <u-col span="2" style="text-align:center;display:flex;">
                      <u-icon
                        name="edit-pen"
                        :color="$theme.u_type_primary"
                        size="32"
                        style="flex: 1;"
                        v-if="!isDisabled"
                        @tap="handlerEditCig(sItem, nRecord.itemUuid)"
                      ></u-icon>
                      <u-icon
                        name="trash"
                        color="red"
                        size="32"
                        style="margin-left: 5px;flex: 1;" 
                        v-if="!isDisabled"
                        @tap="handlerDeleteCig(sItem, nRecord.itemUuid)"
                      ></u-icon>
                    </u-col>
                  </u-row>
                </view>
                <!-- 嫌疑人信息 -->
                <view style="padding-left: 10px;" v-if="personsMap[nRecord.itemUuid]">
                  <u-row gutter="16" v-for="(pItem, pIdx) in personsMap[nRecord.itemUuid]" :key="pIdx">
                    <u-col span="9">
                      <view class="title" v-if="!isDisabled">
                        {{ pItem.personName }}
                      </view>
                      <view class="title view-title" v-else @tap="handlerEditPerson(pItem, nRecord.itemUuid)">
                        {{ pItem.personName }}
                      </view>
                    </u-col>
                    <u-col span="3" style="text-align:center;display:flex;">
                      <u-icon
                        name="edit-pen"
                        :color="$theme.u_type_primary"
                        size="32"
                        style="flex: 1;"
                        v-if="!isDisabled"
                        @tap="handlerEditPerson(pItem, nRecord.itemUuid)"
                      ></u-icon>
                      <u-icon
                        name="trash"
                        color="red"
                        size="32"
                        style="margin-left: 5px;flex: 1;" 
                        v-if="!isDisabled"
                        @tap="handlerDeletePerson(pItem, nRecord.itemUuid)"
                      ></u-icon>
                    </u-col>
                  </u-row>
                </view>  
                <!-- 涉案车辆信息 -->
                <view style="padding-left: 10px;" v-if="carMap[nRecord.itemUuid]">
                  <u-row gutter="16" v-for="(carItem, cIdx) in carMap[nRecord.itemUuid]" :key="cIdx">
                    <u-col span="9">
                      <view class="title" v-if="!isDisabled">
                        {{ carItem.carNum }}
                      </view>
                      <view class="title view-title" v-else @tap="handlerEditCar(carItem, nRecord.itemUuid)">
                        {{ carItem.carNum }}
                      </view>
                    </u-col>
                    <u-col span="3" style="text-align:center;display:flex;">
                      <u-icon
                        name="edit-pen"
                        :color="$theme.u_type_primary"
                        size="32"
                        style="flex: 1;"
                        v-if="!isDisabled"
                        @tap="handlerEditCar(carItem, nRecord.itemUuid)"
                      ></u-icon>
                      <u-icon
                        name="trash"
                        color="red"
                        size="32"
                        style="margin-left: 5px;flex: 1;" 
                        v-if="!isDisabled"
                        @tap="handlerDeleteCar(carItem, nRecord.itemUuid)"
                      ></u-icon>
                    </u-col>
                  </u-row>
                </view> 
                <!-- 涉案窝点信息 -->
                <view style="padding-left: 10px;" v-if="densMap[nRecord.itemUuid]">
                  <u-row gutter="16" v-for="(densItem, dIdx) in densMap[nRecord.itemUuid]" :key="dIdx">
                    <u-col span="9">
                      <view class="title" v-if="!isDisabled">
                        {{ densItem.densName }}
                      </view>
                      <view class="title view-title" v-else @tap="handlerEditDens(densItem, nRecord.itemUuid)">
                        {{ densItem.densName }}
                      </view>
                    </u-col>
                    <u-col span="3" style="text-align:center;display:flex;">
                      <u-icon
                        name="edit-pen"
                        :color="$theme.u_type_primary"
                        size="32"
                        style="flex: 1;"
                        v-if="!isDisabled"
                        @tap="handlerEditDens(densItem, nRecord.itemUuid)"
                      ></u-icon>
                      <u-icon
                        name="trash"
                        color="red"
                        size="32"
                        style="margin-left: 5px;flex: 1;" 
                        v-if="!isDisabled"
                        @tap="handlerDeleteDens(densItem, nRecord.itemUuid)"
                      ></u-icon>
                    </u-col>
                  </u-row>
                </view> 
                <u-input
                  v-if="nRecord.operateType == '91403'"
                  style="margin: 5px 15px 5px 15px;"
                  :placeholder="'请输入' + nRecord.itemName"
                  type="text"
                  :border="true" 
                  :disabled="isDisabled"
                  v-model="checkObj[nRecord.checkKey]"
                />
                <!-- textarea大文本 -->
                <u-field
                  type="textarea"
                  placeholder="请输入"
                  :label="nRecord.itemName"
                  label-width="120"
                  style="height: 120px;"
                  :disabled="isDisabled"
                  v-if="nRecord.operateType == '91404'"
                  v-model="checkObj[nRecord.checkKey]"
                >
                </u-field>
                <!-- 图片上传 -->
                <u-card style="margin-left:30rpx" :title="nRecord.itemName" v-else-if="nRecord.operateType == '91405'">
                  <view class="" slot="body">
                    <view class="u-body-item u-flex u-border-bottom u-col-between u-p-t-0">
                      <view class="u-body-item-title u-line-2">
                        <upload-images
                          :url="uploadFile"
                          :length="picMaxCount"
                          :header="header"
                          :bizId="menuData.checkInfo.checkUuid + '-' +nRecord.itemUuid"
                          :extForm="{fiGroupCode: $FILE_GROUP_TYPE.m_check_attr,bizId:menuData.checkInfo.checkUuid + '-' +nRecord.itemUuid, itemUuid: nRecord.itemUuid}"
                          :canDel="!isDisabled"
                          :del-url="delUrl"
                          :can-add="!isDisabled"
                          :renderImages="renderImages"
                          :onSuccess="handlerUploadImg"
                          :ref="'upload' + nRecord.itemUuid"
                        >
                        </upload-images>
                      </view>
                    </view>
                  </view>
                </u-card>
                <!-- 第四层 -->
                <view v-for="(fRecord, nrIdx) in nRecord.workItems" v-show="checkObj[nRecord.checkKey]" :key="nrIdx">
                  <!-- 图片上传 -->
                  <u-card style="margin-left:60rpx" :title="fRecord.itemName" v-if="fRecord.operateType == '91405'">
                    <view class="" slot="body">
                      <view class="u-body-item u-flex u-border-bottom u-col-between u-p-t-0">
                        <view class="u-body-item-title u-line-2">
                          <upload-images
                            :url="uploadFile"
                            :length="picMaxCount"
                            :header="header"
                            :bizId="menuData.checkInfo.checkUuid + '-' +fRecord.itemUuid"
                            :extForm="{fiGroupCode: $FILE_GROUP_TYPE.m_check_attr,bizId:menuData.checkInfo.checkUuid + '-' +fRecord.itemUuid, itemUuid: fRecord.itemUuid}"
                            :canDel="!isDisabled"
                            :del-url="delUrl"
                            :can-add="!isDisabled"
                            :renderImages="renderImages"
                            :onSuccess="handlerUploadImg"
                            :ref="'upload' + fRecord.itemUuid"
                          >
                          </upload-images>
                        </view>
                      </view>
                    </view>
                  </u-card>
                  <u-input
                    v-else
                    style="margin: 5px 15px 5px 30px;"
                    :placeholder="'请输入' + fRecord.itemName"
                    type="text"
                    :border="true" 
                    :disabled="isDisabled"
                    v-model="fRecord.checkData"
                  />
                </view>
              </view>
            </view>
            <u-select
              :list="record.dealList"
              :mask-close-able="false"
              v-model="record.showSelect" 
              @cancel="handlerCloseSelect(record)"
              @confirm="handlerConfirm($event, record)"
            ></u-select>
          </view>
        </view>
        <u-select
          :list="item.dealList"
          :mask-close-able="false"
          v-model="item.showSelect" 
          @cancel="handlerCloseSelect(item)"
          @confirm="handlerConfirm($event, item)"
        ></u-select>
      </view>
      <u-select
        :list="commonDicts"
        :mask-close-able="false"
        v-model="commonDictShow" 
        @cancel="handlerCommonSelect"
        @confirm="handlerCommonConfirm($event)"
      ></u-select>
      <!-- 卷烟列表 -->
      <u-popup mode="bottom" height="100%" border-radius="16" v-model="cigarSelectOpen">
        <cigar-list @back="handlerCigar"></cigar-list>
      </u-popup>
      <!-- 卷烟信息 -->
      <u-popup mode="bottom" height="100%" border-radius="16" v-model="cigarOpen">
        <add-cigar :cigarData="cigarInfo" :isDisabled="isDisabled" @back="handlerCigarBack"></add-cigar>
      </u-popup>
      <!-- 涉案车辆信息 -->
      <u-popup mode="bottom" height="100%" border-radius="16" v-model="carOpen">
        <case-car :carData="carInfo" :isDisabled="isDisabled" @back="handlerCarBack"></case-car>
      </u-popup>
      <!-- 涉案窝点信息 -->
      <u-popup mode="bottom" height="100%" border-radius="16" v-model="densOpen">
        <case-dens ref="densRef" :densData="densInfo" :isDisabled="isDisabled" @back="handlerDensBack"></case-dens>
      </u-popup>
      <view class="inflow-alert-info" v-if="checkObj[preFix + '34020101'] == '普通案件'">
        提示：检查提交后请做“普通案件”
      </view>
      <!-- 嫌疑人员 -->
      <u-popup mode="bottom" height="100%" border-radius="16" v-model="personInfoOpen">
        <suspect-person :personData="personInfo" :isDisabled="isDisabled" @back="handlerPersonBack"></suspect-person>
      </u-popup>
    </view>
  </view>
</template>
<script>
import suspectPerson from './suspect-person.vue';
import addCigar from './addCigar.vue';
import cigarList from './cigarList.vue';
import UploadImages from "@/components/upload-images.vue";
import commonService from '@/service/eCigar/common.service';
import zjCommonService from "@/service/common/common.service";
import CaseCar from './case-car.vue';
import CaseDens from './case-dens.vue';
import {CHECK_ITEM_BIND_GIS_SUB_TYPE,} from "@/service/check/mapping/enum.js";
export default {
  name: "UniversalCom",
  components: { 
    cigarList, 
    addCigar, 
    suspectPerson, 
    UploadImages,
    CaseCar,
    CaseDens,
  },
  props: {
    menuData: {
      type: Object,
      default: () => {},
    },
    recordDatas: {
      type: Array,
      default: () => [],
    },
    checkGuides: {  // 检查作业指导书信息
      type: Object,
      default: () => {},
    },
    isDisabled: {   // 是否可编辑
      type: Boolean,
      default: false,
    },
    actionEvent:{  // 地图定位
      type: Object,
      default: () => {},
    },
    retailer:{ // 零售户info
      type: Object,
      default: () => {},
    },
    prevCheckInfo:{ // 参考违规数据
      type:Array,
      default: () => [],
    },
  },
  data() {
    return {
      records: this.recordDatas,
      checkObj: {},
      cigsMap: {},  // 添加的问题卷烟信息
      addItemUuid: '',  // 当前添加卷烟的指标
      preFix: 'L',  // 指标前缀
      mainLabelStyle: {
        // 'color': '#000',
        // 'fontWeight': '600',
      },
      dealMap: {},  // 处理方式字典
      personInfoOpen: false,
      personInfo: {}, // 嫌疑人信息
      personsMap: {}, // 添加的嫌疑人信息
      addSuspectUuid: "", // 当前点击添加嫌疑人指标项
      vehicleMap: {},
      storagesMap: {},
      busiTypeDicts: this.$store.state.dicts['RETAILER_BUSI_TYPE'],  // 商圈字典数据
      busiTypeShow: false,
      envDicts: this.$store.state.dicts['RETAILER_ENV_TYPE'], // 地理环境字典数据
      envShow: false,
      recordItem: {}, // 当前点击的指标项
      commonDicts: [],  // 公共字典
      commonDictShow: false,  // 公共字典显示
      recordsStorage: uni.getStorageSync('APCD_CHECK_RECORDS') || [], // 缓存的检查项数据
      cigarSelectOpen: false, // 违法违规问题
      cigarOpen: false,
      cigarInfo: {},
      uploadFile: commonService.uploadFile,
      delUrl: commonService.deleteFile,
      header:{
        tk: uni.getStorageSync("tk"),
        // "content-type":'application/json',
      },
      plainCheckRecords: [],  // 存放解析nextRecords后的指标
      illegalCigType: {'3402050101': '01', '3402050201': '02', '3402050301': '03',}, // 经营假烟、走私烟、非渠道烟映射关系
      densOpen:false,
      densInfo: {}, // 窝点信息
      densMap: {}, // 添加的涉案窝点信息
      addDensUuid: "", // 当前点击添加窝点指标项
      carOpen:false,
      carInfo: {}, // 车辆信息
      carMap: {}, // 添加的涉案车辆信息
      addCarUuid: "", // 当前点击添加车辆指标项
      picMaxCount: 5, // 上传图片最大张数
      wiIconStyle:{
        color: this.$theme.u_type_error,
      },
      itemUuidMap:{
        'relRetailers':'34020501', // 关联经营户
        'personInfos':'34020638',  // 从业人员
        'storageInfos':'34020641',  // 仓储信息
        'vehicleInfoMts':'34020640', // 车辆信息
        'supplySources':'34020639',   // 货源来源
        'caseCarInfos':'340201040401', // 涉案车辆
        'caseDensInfos':'340201040101', // 涉案窝点
      },
			// h5端部分浏览器input设置disabled后点击事件失效 2023-10-25 fsx start
			pointerStyle: {
			  marginRight: "5px",
				pointerEvents: "none !important"
			},
			// h5端部分浏览器input设置disabled后点击事件失效 2023-10-25 fsx start
    }
  },
  watch: {
    menuData(v) {
      console.log("监听", v);
    },
    actionEvent(v){
      if(v.event == 'pos' && this.densInfo){
        this.$refs.densRef.densForm.gis = v.value.longitude + ',' + v.value.latitude;
        this.$refs.densRef.densForm.gisX = v.value.longitude;
        this.$refs.densRef.densForm.gisY = v.value.latitude;
      }
    },
  },
  created () {
    // 还原检查项数据
    let storageRecordMap = {};
    this.menuData.records.forEach(r => storageRecordMap[this.preFix + r.itemUuid] = this.initRecordVal(r));
    console.log("this.menuData:",this.menuData);
    // 从检查任务对象中还原仓储信息
    this.menuData.storageInfos && this.menuData.storageInfos.forEach(p => {
      p['itemUuid'] = this.itemUuidMap['storageInfos'];
      this.storagesMap[p.itemUuid] = this.storagesMap[p.itemUuid] ? [p, ...this.storagesMap[p.itemUuid],] : [p,];
    });
    // 从检查任务对象中还原从车辆信息
    this.menuData.vehicleInfoMts && this.menuData.vehicleInfoMts.forEach(p => {
      p['itemUuid'] = this.itemUuidMap['vehicleInfoMts'];
      this.vehicleMap[p.itemUuid] = this.vehicleMap[p.itemUuid] ? [p, ...this.vehicleMap[p.itemUuid],] : [p,];
    });
    // 从检查任务对象中还原卷烟信息
    this.menuData.problemCigInfos && this.menuData.problemCigInfos.forEach(p => {
      // p.itemUuid = reviseCigType[p.cigType];
      this.cigsMap[p.itemUuid] = this.cigsMap[p.itemUuid] ? [p, ...this.cigsMap[p.itemUuid],] : [p,];
    });
    // 从检查任务对象中还原线索登记的人员信息
    this.menuData.suspectedPeoples && this.menuData.suspectedPeoples.forEach(p => {
      this.personsMap[p.itemUuid] = this.personsMap[p.itemUuid] ? [p, ...this.personsMap[p.itemUuid],] : [p,];
    });
    // 从检查任务对象中还原车辆信息
    {{ this.menuData.caseCarInfos }}
    this.menuData.caseCarInfos && this.menuData.caseCarInfos.forEach(p => {
      p['itemUuid'] = this.itemUuidMap['caseCarInfos'];
      this.carMap[p.itemUuid] = this.carMap[p.itemUuid] ? [p, ...this.carMap[p.itemUuid],] : [p,];
    });
    // 从检查任务对象中还原窝点信息
    this.menuData.caseDensInfos && this.menuData.caseDensInfos.forEach(p => {
      p['itemUuid'] = this.itemUuidMap['caseDensInfos'];
      this.densMap[p.itemUuid] = this.densMap[p.itemUuid] ? [p, ...this.densMap[p.itemUuid],] : [p,];
    });
    let dicts = this.$store.state.dicts['M_CHECK_HANDLE_RESULT'];
    dicts.forEach(d => this.dealMap[d.bcbCode] = d.bcbName);
    this.records.forEach(r => {
      r.checkHandleResult && (r.checkHandleResultLabel = this.dealMap[r.checkHandleResult]);
      r.checkKey = this.preFix + r.itemUuid;
      this.$set(this.checkObj, r.checkKey, storageRecordMap[r.checkKey] || this.initRecordVal(r));
      // 子项
      r.workItems && r.workItems.forEach(nr => {
        nr.checkHandleResult && (nr.checkHandleResultLabel = this.dealMap[nr.checkHandleResult]);
        nr.checkKey = this.preFix + nr.itemUuid;
        this.$set(this.checkObj, nr.checkKey, storageRecordMap[nr.checkKey] || this.initRecordVal(nr));
        // 子子项
        nr.workItems && nr.workItems.forEach(zzr => {
          zzr.checkHandleResult && (zzr.checkHandleResultLabel = this.dealMap[zzr.checkHandleResult]);
          zzr.checkKey = this.preFix + zzr.itemUuid;
          this.$set(this.checkObj, zzr.checkKey, storageRecordMap[zzr.checkKey] || this.initRecordVal(zzr));
        });
        // 处理方式
        if (nr.jgsxDealUuidZj) {
          nr.dealList = [{label:'请选择',value:'',},];
          nr.jgsxDealUuidZj.split(",").forEach(m => nr.dealList.push({label: this.dealMap[m], value: m, itemUuid: nr.itemUuid,}));
        }
      });
      // 处理方式
      if (r.jgsxDealUuidZj) {
        r.dealList = [{label:'请选择',value:'',},];
        r.jgsxDealUuidZj.split(",").forEach(j => r.dealList.push({label: this.dealMap[j], value: j, itemUuid: r.itemUuid,}));
      }
    });
    console.log("checkObj回显", this.checkObj);
  },
  methods: {
    // 回显数据处理
    initRecordVal(cRecord) {
      if (cRecord.operateType == '91401') {   // switch选择
        return cRecord.checkData ? cRecord.checkData === 'true' || cRecord.checkData === true || cRecord.checkData === '1' || cRecord.checkData === 1 : cRecord.defaultValue === '1';// cRecord.defaultValue === '1'
      } else if (cRecord.operateType == '91402') {  // 下拉选
        if (cRecord.contentOptions) {
          let dicMap = {};
          (this.$store.state.dicts[cRecord.contentOptions] || []).forEach(d => dicMap[d.bcbCode] = d.bcbName);
          return dicMap[cRecord.checkData]
        }
        return cRecord.checkDataLabel;
      }else if(cRecord.operateType == '91421'){
        zjCommonService.getRetailerLicGis(this.menuData.checkInfo.retailerUuid, CHECK_ITEM_BIND_GIS_SUB_TYPE[cRecord.itemUuid]).then(dr => {
          if (dr.success) {
            let ar = dr.data || [];
            this.$set(cRecord, "gisData", `-已关联(${ar.length})`);
            this.$set(cRecord, "gisDataList", ar);
          }
        }).catch(e => {
          console.log(e);
        });
      }
      return cRecord.checkData;
    },
    getWarningInfo(itemUUid){
      let tmp = false;
      for (let i = 0; i < this.prevCheckInfo.length; i++) {
        if(itemUUid == this.prevCheckInfo[i].itemUuid){
          tmp = this.prevCheckInfo[i].isTag || false;
          break;
        }
      }
      return tmp ? 'error-circle-fill' : '';
    },
    tapWarning(itemUUid){
      let remark = "";
      for (let i = 0; i < this.prevCheckInfo.length; i++) {
        if(itemUUid == this.prevCheckInfo[i].itemUuid){
          remark = this.prevCheckInfo[i].remark || '';
          break;
        }
      }
      if(!this.$u.test.isEmpty(remark)){
        this.$modal.alert(remark);
      }
    },
    // 是否选中
    handlerSwitch(isChecked, rItem) {
      this.recordItem = rItem;
      if(isChecked){
        if(rItem.creditSituation == '1'){
          this.$modal.alert("此检查项为信用评价项目，请谨慎操作，选中后请务必上传证明材料。",() => {});
        }
      }
      if (this.isDisabled) {
        return false;
      }
      console.log("点击后：",this.checkObj);
    },
    // 显示通用选择框
    handlerSelShow(item) {
      if (this.isDisabled) {
        return false;
      }
      this.recordItem = item;
      if (!item.contentOptions) {
        this.$u.toast(`【${item.itemName}】缺失字典项`);
        return;
      }
      this.commonDicts = this.$store.state.dicts[item.contentOptions];
      this.commonDictShow = true;
    },
    // 显示选择处理方式
    handlerShowSelect(item) {
      if (this.isDisabled) {
        return false;
      }
      item.showSelect = true;
      this.$forceUpdate();
    },
    // 关闭处理方式选择框
    handlerCloseSelect(item) {
      item.showSelect = false;
      this.$forceUpdate();
    },
    // 处理方式
    handlerConfirm(e, item) {
      console.log("处理方式", e, item);
      item.checkHandleResult = e[0].value;
      item.checkHandleResultLabel = e[0].label;
      item.showSelect = false;
      this.$forceUpdate();
    },
    // 选择公共字典
    handlerCommonSelect() {
      this.commonDictShow = false;
      this.$forceUpdate();
    },
    // 公共字典点击确认
    handlerCommonConfirm(e) {
      console.log(e);
      for (let k = 0; k < this.records.length; k++) {
        if (this.records[k].itemUuid === this.recordItem.itemUuid) {
          this.records[k].checkData = e[0].value;
          this.records[k].checkDataLabel = e[0].label;
        }
      }
      // 特殊处理部分字典选中项
      this.dealDictConfirm(e[0]);
      this.commonDictShow = false;
      this.$forceUpdate();
    },
    // 特殊处理部分字典选中项
    dealDictConfirm(eItem = {label: "", value: "",}) {
      // 流入问题，无案件不显示选择项
      if (this.menuData.type == 'in' && this.recordItem.itemUuid == '34020101' && eItem.value == '91500') {
        this.checkObj[this.preFix + this.recordItem.itemUuid] = null;
        return;
      }
      this.checkObj[this.preFix + this.recordItem.itemUuid] = eItem.label;
    },
    // 确定
    handlerSure() {
      // 清洗数据，将树状结构数据转成扁平数据
      this.plainCheckRecords = [];
      console.log(this.records);
      this.recursiveRecords(this.records);
      console.log("清洗后的数据", this.plainCheckRecords);
      // 对扁平数据进行一次赋值
      Object.keys(this.checkObj).forEach(k => this.recursive(this.plainCheckRecords, k));
      // 返回的数据
      let comData = {records: this.plainCheckRecords, comType: this.menuData.type,}
      console.log("处理后的数据", this.plainCheckRecords);
      let dataArr = comData.records;
      if(dataArr){ // 带处理方式的操作必须让选择处理方式
        for (let i = 0; i < dataArr.length; i++) {
          if(!this.$u.test.isEmpty(dataArr[i].jgsxDealUuidZj) && dataArr[i].checkData == true && this.$u.test.isEmpty(dataArr[i].checkHandleResult)){
            this.$u.toast(`请选择${dataArr[i].itemName}的处理方式`);
            return;
          }
        }
        // creditSituation 为1 的数据，子集的数据除过卷烟类型列表意外其他项都不能为空
        let csItems = dataArr.filter((io) => { return io.creditSituation == '1' && io.checkData == true });
        for (let i = 0; i < csItems.length; i++) {
          let csChilds = dataArr.filter((ix) => {
            return ix.operateType != '91411' && ix.itemUuid != csItems[i].itemUuid && ix.itemUuid.indexOf(csItems[i].itemUuid) >= 0;
          });
          for (let k = 0; k < csChilds.length; k++) {
            if(this.$u.test.isEmpty(csChilds[k].checkData)){
              this.$u.toast(`请填充${csItems[i].itemName}的${csChilds[k].itemName}的信息`);
              return;
            }
          }
        }
      }
      if (comData.comType == 'in') { 
        // 组装线索登记的人员信息
        comData.suspectedPeoples = [];
        Object.keys(this.personsMap).forEach(k => comData.suspectedPeoples = [...comData.suspectedPeoples, ...this.personsMap[k],]);
        // 组装登记的卷烟信息
        comData.problemCigInfos = [];
        Object.keys(this.cigsMap).forEach(k => comData.problemCigInfos = [...comData.problemCigInfos, ...this.cigsMap[k],]);
        // 组装涉案窝点信息
        comData.caseDensInfos = [];
        Object.keys(this.densMap).forEach(k => comData.caseDensInfos = [...comData.caseDensInfos, ...this.densMap[k],]);
        // 组装涉案车辆信息
        comData.caseCarInfos = [];
        Object.keys(this.carMap).forEach(k => comData.caseCarInfos = [...comData.caseCarInfos, ...this.carMap[k],]);		
      } 
      
      this.$emit("ok", comData);
    },
    // 将树状结构数据清洗成扁平数据
    recursiveRecords(arr) {
      arr.forEach(item => {
        let nItem = this.$u.deepClone(item);
        delete nItem.workItems;
        this.plainCheckRecords.push(nItem);
        if (item.workItems && item.workItems.length > 0) {
          this.recursiveRecords(item.workItems)
        }
      })
    },
    // 递归赋值选中项（作废）
    recursive(arr, ck) {
      arr.forEach(item => {
        if (item.itemUuid == ck.replace(this.preFix, "")) {
          // 91402下拉选：checkObj中保存的是label，此处不再赋值
          // 91405图片上传：附件url在上传成功后处理，此处不再赋值
          if (item.operateType != '91402' && item.operateType != '91405') {
            item.checkData = this.checkObj[ck];
          }
        } else {
          if (item.workItems) {
            this.recursive(item.workItems, ck)
          }
        }
      })
    },
    // 关闭
    handlerBack() {
      this.$emit("close", true);
    },
    // 添加卷烟
    handlerAddCig(rc) {
      this.addItemUuid = rc.itemUuid;
      this.cigarSelectOpen = true;
    },
    // 添加卷烟信息
    handlerCigar(cig) {
      if (cig) {
        let nCig = {
          "checkUuid": this.menuData.checkInfo.checkUuid,
          "cigSource": cig.cigSource,
          "cigSourceName": cig.cigSourceName,
          "cigType": this.illegalCigType[this.addItemUuid],
          "packCode": cig.packCode,
          "productName": cig.productName,
          "productUuid": cig.productUuid,
          "qty": cig.qty,
          "remark": cig.remark,
          "itemUuid": this.addItemUuid,
          "retailerUuid": this.menuData.checkInfo.retailerUuid,
        };
        let cigs = this.cigsMap[this.addItemUuid];
        if (cigs) {
          let existCigs = cigs.filter(c => c.productUuid == nCig.productUuid);
          if (existCigs.length > 0) {
            this.$u.toast(`【${nCig.productName}】已存在`);
          } else {
            this.cigsMap[this.addItemUuid] = [nCig, ...cigs,];
          }
        } else {
          this.cigsMap[this.addItemUuid] = [nCig,];
        }
      }
      this.cigarSelectOpen = false;
    },
    // 编辑已录入的卷烟信息
    handlerCigarBack(cig) {
      if (cig) {
        for (let k = 0; k < this.cigsMap[this.addItemUuid].length; k++) {
          if (this.cigsMap[this.addItemUuid][k].productUuid == cig.productUuid) {
            this.cigsMap[this.addItemUuid][k] = cig;
          }
        }
      }
      this.cigarOpen = false;
    },
    // 编辑或预览卷烟信息
    handlerEditCig(cInfo, cItemUuid) {
      this.cigarInfo = cInfo;
      this.addItemUuid = cItemUuid;
      this.cigarOpen = true;
    },
    // 删除卷烟
    handlerDeleteCig(cInfo, cItemUuid) {
      this.$modal.confirm(`确定删除【${cInfo.productName}】吗?`, () => {
        this.cigsMap[cItemUuid] = this.cigsMap[cItemUuid].filter(c => c.productUuid != cInfo.productUuid);
        this.$forceUpdate();
      });
    },
    // 添加疑似收购人员
    handlerAddPersons(rc) {
      console.log("添加疑似收购人员", rc);
      this.addSuspectUuid = rc.itemUuid;
      this.personInfo = {};
      this.personInfoOpen = true;
    },
    // 嫌疑人登记返回
    handlerPersonBack(p) {
      if (p) {
        !p.uuid && (p.uuid = new Date().getTime());
        p.itemUuid = this.addSuspectUuid;
        p.checkUuid = this.menuData.checkInfo.checkUuid;
        p.retailerUuid = this.menuData.checkInfo.retailerUuid;
        let ps = this.personsMap[this.addSuspectUuid];
        if (ps) {
          let existPs = ps.filter(c => c.uuid != p.uuid);
          existPs.push(p);
          this.personsMap[this.addSuspectUuid] = [...existPs,];
        } else {
          this.personsMap[this.addSuspectUuid] = [p,];
        }
      }
      this.personInfoOpen = false;
    },
   
    // 编辑嫌疑人信息
    handlerEditPerson(pInfo, pItemUuid) {
      this.personInfo = pInfo;
      this.addSuspectUuid = pItemUuid;
      this.personInfoOpen = true;
    },
    // 删除嫌疑人
    handlerDeletePerson(pInfo, pItemUuid) {
      this.$modal.confirm(`确定删除【${pInfo.personName}】吗?`, () => {
        this.personsMap[pItemUuid] = this.personsMap[pItemUuid].filter(c => c.uuid != pInfo.uuid);
        this.personInfo = {};
        this.$forceUpdate();
      });
    },
    // 添加涉案窝点信息
    handlerAddDens(rc) {
      console.log("添加涉案窝点信息", rc);
      this.addDensUuid = rc.itemUuid;
      this.densOpen = true;
    },
    // 涉案窝点登记返回
    handlerDensBack(d) {
      if (d) {
        !d.uuid && (d.uuid = new Date().getTime());
        d.itemUuid = this.addDensUuid;
        d.checkUuid = this.menuData.checkInfo.checkUuid;
        d.retailerUuid = this.menuData.checkInfo.retailerUuid;
        let ps = this.densMap[this.addDensUuid];
        if (ps) {
          let existPs = ps.filter(c => c.uuid != d.uuid);
          existPs.push(d);
          this.densMap[this.addDensUuid] = [...existPs,];
        } else {
          this.densMap[this.addDensUuid] = [d,];
        }
      }
      this.densOpen = false;
    },
    // 编辑窝点信息
    handlerEditDens(densInfo, dItemUuid) {
      this.densInfo = densInfo;
      this.addDensUuid = dItemUuid;
      this.densOpen = true;
    },
    // 删除窝点
    handlerDeleteDens(densInfo, dItemUuid) {
      this.$modal.confirm(`确定删除【${densInfo.densName}】吗?`, () => {
        this.densMap[dItemUuid] = this.densMap[dItemUuid].filter(c => c.uuid != densInfo.uuid);
        this.densInfo = {};
        this.$forceUpdate();
      });
    },
    // 添加涉案车辆信息
    handlerAddCar(rc) {
      console.log("添加涉案车辆信息", rc);
      this.addCarUuid = rc.itemUuid;
      this.carOpen = true;
    },
    // 涉案车辆登记返回
    handlerCarBack(car) {
      if (car) {
        !car.uuid && (car.uuid = new Date().getTime());
        car.itemUuid = this.addCarUuid;
        car.checkUuid = this.menuData.checkInfo.checkUuid;
        car.retailerUuid = this.menuData.checkInfo.retailerUuid;
        let ps = this.carMap[this.addCarUuid];
        if (ps) {
          let existPs = ps.filter(c => c.uuid != car.uuid);
          existPs.push(car);
          this.carMap[this.addCarUuid] = [...existPs,];
        } else {
          this.carMap[this.addCarUuid] = [car,];
        }
      }
      this.carOpen = false;
    },
    // 编辑车辆信息
    handlerEditCar(carInfo, cItemUuid) {
      this.carInfo = carInfo;
      this.addCarUuid = cItemUuid;
      this.carOpen = true;
    },
    // 删除车辆
    handlerDeleteCar(carInfo, cItemUuid) {
      this.$modal.confirm(`确定删除【${carInfo.carNum}】吗?`, () => {
        this.carMap[cItemUuid] = this.carMap[cItemUuid].filter(c => c.uuid != carInfo.uuid);
        this.carInfo = {};
        this.$forceUpdate();
      });
    },
    handlerOpen(idx, sItemUuid) {
      this.cigsMap[sItemUuid].map((c, i) => {
        c.show = i == idx;
      });
      this.$forceUpdate();
    },
    // 渲染上传的图片
    renderImages(vm){
      return commonService.findFilesByBizId('', vm.bizId).then(r => {
        r.data.forEach(i => i = this.reInitUploadImg(i));
        return r.data;
      });
    },
    // 监听上传图片变化
    handlerUploadImg(imgList, rsImg, vm) {
      console.log("上传文件变化了", imgList, rsImg, vm);
      let iUrls = [];
      imgList.forEach(m => iUrls.push(m.fileUuid));
      if (!rsImg) {
        this.putImgValue(this.records, vm.extForm.itemUuid, iUrls.join(","));
        return imgList;
      }
      imgList.push(this.reInitUploadImg(rsImg));
      iUrls.push(rsImg.fileUuid);
      this.putImgValue(this.records, vm.extForm.itemUuid, iUrls.join(","));
      return imgList;
    },
    // 处理已上传的附件路径
    reInitUploadImg(uImg) {
      uImg.src = `${commonService.baseUrl}/commonfile/filestore/downloadFile.do?fileId=${uImg.gfiId}&tk=${uni.getStorageSync("tk")}`;
      uImg.filePath = uImg.src;
      uImg.fileUuid = uImg.gfiId;
      return uImg;
    },
    // 给指标赋值图片地址
    putImgValue(arr, itUuid, imgUrls) {
      arr.forEach(item => {
        if (item.itemUuid == itUuid) {
          item.checkData = imgUrls;
          return;
        } else {
          if (item.workItems) {
            this.putImgValue(item.workItems, itUuid, imgUrls)
          }
        }
      })
    },
    /**
	 * 跳转关联
	 * @param {Object} obj
	 */
    handlerMergeGis(obj){
      this.setRouteParam({
        retailer: this.menuData.checkInfo, // 持证户信息
        itemType: CHECK_ITEM_BIND_GIS_SUB_TYPE[obj.itemUuid],
        justView: this.isDisabled,
        obj: obj,
        ownAreaInfo: {
          orgName: this.retailer.orgName,
          orgUuid: this.retailer.orgUuid,
          longitude: this.retailer.longitude,
          latitude: this.retailer.latitude,
        },
      });
      this.$u.route("/pages/check/poiCollect/surroundingsGis");
    },
    updateGisData(cRecord){
      zjCommonService.getRetailerLicGis(this.menuData.checkInfo.retailerUuid, CHECK_ITEM_BIND_GIS_SUB_TYPE[cRecord.itemUuid]).then(dr => {
        if (dr.success) {
          let ar = dr.data || [];
          this.$set(cRecord, "gisData", `-已关联(${ar.length})`);
          this.$set(cRecord, "gisDataList", ar);
        }
      }).catch(e => {
        console.log(e);
      });
    },
  },
}
</script>
<style lang="scss" scoped>
.title {
  font-size: 15px;
  color: #666;
  font-weight: 600;
  margin: 5px 10px;
}
.view-title {
  color: rgb(41, 121, 255);
}
.sub-title {
  color: #666;
  margin: 3px 10px;
}
// /deep/ .u-card { 
//   margin: 0px !important;
// }
/deep/ .u-card__head, /deep/ .u-card__body {
  padding: 8px 16px !important;
}

.u-body-item {
  font-size: 32rpx;
  color: #333;
  padding: 20rpx 10rpx;
}
.inflow-alert-info {
  padding: 10px 15px;
  color: orangered;
}



</style>